/*
 * @Author: hulu20 - 563293401@qq.com
 * @Date: 2023-02-09 16:47:25
 * @Last Modified by: hulu20 - 563293401@qq.com
 * @Last Modified time: 2023-02-15 16:15:02
 * @Desc: Metrics 路由
 */
package router

import (
	"tasktor/internal/service"

	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/os/gctx"

	"github.com/prometheus/client_golang/prometheus/promhttp" // promhttp.Handler()
)

func Metrics(s *ghttp.Server) {
	// 加载自定义指标func
	service.MetricsService.RecordMetrics(gctx.New())
	// prometheus metrics api
	// prometheus 集成方法
	s.BindHandler("/metrics", func(r *ghttp.Request) {
		promhttp.Handler().ServeHTTP(r.Response.Writer, r.Request)
	})
}
